from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCD_DRG

def group(record):
  adrg_zd=["B49.x05","B49.x08","B49.x09","C31.100","C44.304","D14.000x005","D14.000x007","D14.000x009","D14.000x010","D14.001","D14.003","D14.004","D14.102","D16.403","D18.000x503","D18.000x504","D36.700x007","G47.300x001","G47.300x037","G47.301","J01.300","J01.900","J05.100","J30.400","J31.000","J31.001","J32.000","J32.001","J32.003","J32.005","J32.102","J32.200","J32.400","J32.400x001","J32.800x006","J32.800x008","J32.801","J32.803","J32.900","J33.000","J33.002","J33.003","J33.801","J33.802","J33.805","J33.900","J34.000x010","J34.002","J34.007","J34.101","J34.102","J34.103","J34.104","J34.106","J34.108","J34.200","J34.800x009","J34.800x033","J34.801","J34.804","J34.809","J34.810","J35.000","J38.102","J39.224","K10.211","K12.204","M95.005","R04.000","S02.200","S02.211"]
  adrg_zd1=[]
  adrg_ss=["21.0904","21.1x01","21.1x04","21.3101","21.3102","21.3103","21.3104","21.3109","21.3200x003","21.3200x008","21.4x00","21.5x00","21.5x00x004","21.5x01","21.6100x002","21.6101","21.6103","21.6200","21.6900x009","21.6901","21.6902","21.6903","21.6904","21.7100","21.7200","21.7200x001","21.9100","21.9101","21.9900x006","21.9901","22.2x00x009","22.2x01","22.2x02","22.3100x002","22.3900x002","22.3900x003","22.4100x005","22.4101","22.4200x009","22.4201","22.4202","22.5002","22.5100","22.5102","22.5202","22.5203","22.5204","22.5300","22.5300x004","22.5301","22.6001","22.6002","22.6200x004","22.6201","22.6300x011","22.6301","22.6302","22.6303","22.6402","22.6403","22.7100x004","22.7902","22.9x01"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合DD2入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCD_DRG.DD29_group(record):
      return 'DD29'

    return 'DD2'
  else:
    return ''

